package com.wing.cabinet.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;

/**
 * 品牌平均寿命
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("cab_brand_life")
public class BrandLife extends BaseEntity<BrandLife> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * year
     */
    private Integer year;

    /**
     * month
     */
    private Integer month;

    /**
     * 寿命达成率
     */
    private BigDecimal rate;

    /**
     * 品牌
     */
    private Long brandId;

    /**
     * useTime
     */
    private Integer useTime;

    /**
     * sumTime
     */
    private Integer sumTime;

    /**
     * 企业编码
     */
    private String enterpriseCode;

    private Integer quantity;

    private LifeUnit lifeUnit;

    private BigDecimal sumRate;

    public enum LifeUnit implements IEnum<Integer> {

        /**
         * 分钟
         */
        minute(1,"分钟"),
        /**
         * 个数
         */
        number(2,"个数");

        private int code;
        private String desc;

        LifeUnit(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
        @JsonCreator
        public static LifeUnit jsonCreator(String name) {
            if (StringUtils.isNotBlank(name)) {
                for (LifeUnit item : values()) {
                    if (item.name().equals(name.trim())) {
                        return item;
                    }
                }
            }
            return null;
        }
    }

}
